import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import router from './utils/router'
import {createStore} from "vuex";
import {toRaw} from "@vue/reactivity";
import './style.css'
const app = createApp(App)
const store = createStore({
    state () {
        return {
            expression:3,
            index:3,
        }
    },
    mutations: {
        getFaceExpression (state,obj) {
            let expressData=obj
            let arr=[]
            arr.push(expressData.angry)
            arr.push(expressData.disgusted)
            arr.push(expressData.fearful)
            arr.push(expressData.happy)
            arr.push(expressData.neutral)
            arr.push(expressData.sad)
            arr.push(expressData.surprised)
            let closestTo1Index = 0;

            for(let i = 1; i < arr.length; i++) {
                if(Math.abs(arr[i] - 1) < Math.abs(arr[closestTo1Index] - 1)) {
                    closestTo1Index = i;
                }
            }
            console.log(closestTo1Index,"下标")
            console.log(arr)
            state.index=closestTo1Index

        }
    }
})
app.use(store)
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(router) // 可以使用this.$router和this.$route

app.mount('#app')
